import type { CartItem, CartParams } from '@/types/cart'
import { my_request } from '@/utils/http'
// 添加购物车
export const addCartAPI = (data: CartParams) => {
  return my_request({
    method: 'POST',
    url: '/member/cart',
    data,
  })
}
// 获取购物车数据
export const getCartAPI = () => {
  return my_request<CartItem[]>({
    method: 'GET',
    url: '/member/cart',
  })
}
// 删除购物车
export const deleteCartGoodByIdAPI = (ids: string[]) => {
  return my_request({
    method: 'DELETE',
    url: '/member/cart',
    data: ids,
  })
}
// 修改购物车商品数量
export const updateSelectedBySkuId = (
  skuId: string,
  data: {
    selected?: boolean
    count?: number
  },
) => {
  return my_request({
    method: 'PUT',
    url: `/member/cart/${skuId}`,
    data,
  })
}
// 修改全选状态
export const changeSelectedById = (
  data: {
    selected: boolean
    ids?: string[]
  },
  id?: string,
) => {
  return my_request({
    method: 'PUT',
    url: `/member/cart/selected`,
    data,
  })
}
